﻿using System.Linq;
using NUnit.Framework;

namespace CryptoQrUtilities.UnitTests
{
    [TestFixture]
    public class QrUtiltiesWrapperTests
    {
        [Test]
        public void EncodeTextDecodeTest()
        {
            const string c_test = "Test";
            var qrUtils = new QrUtilitiesWrapper();

            using (var qrBitmap = qrUtils.GetQrEncoding(c_test))
            {
                var decodeResult = qrUtils.GetQrDecoding(qrBitmap);

                Assert.NotNull(decodeResult, "QR could not be decoded.");

                Assert.IsTrue(c_test.Equals(decodeResult.Text), "QR text was not decoded ok.");
            }
        }

        [Test]
        public void Base64EncodeDecodeTest()
        {
            var buffer = new byte[] { 0, 1, 2, 4, 5, 6, 7, 8, 9 };
            var processed = buffer.ToBase64().FromBase64();

            Assert.AreEqual(buffer.Length, processed.Length, "Matching length.");
            Assert.IsTrue(buffer.SequenceEqual(processed), "Matching bytes one by one.");
        }
    }
}

